Socket
Socket
Sign inDemoInstall

@conventional-changelog/git-client

Package Overview
Dependencies
5
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @conventional-changelog/git-client

Simple git client for conventional changelog packages.


Version published
Weekly downloads
43K
decreased by-16.22%
Maintainers
2
Install size
188 kB
Created
Weekly downloads
 

Readme

Source

@conventional-changelog/git-client

ESM-only package NPM version Node version Dependencies status Install size Build status Coverage status

Simple git client for conventional changelog packages.


Install   •   Usage   •   API

Install

# pnpm
pnpm add @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser
# yarn
yarn add @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser
# npm
npm i @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser

Note: conventional-commits-filter and conventional-commits-parser are required only if you need ConventionalGitClient#getCommits method.

Usage

import {
  GitClient,
  ConventionalGitClient
} from '@conventional-changelog/git-client'

// Basic git client
const client = new GitClient(process.cwd())

await client.add('package.json')
await client.commit({ message: 'chore: release v1.0.0' })
await client.tag({ name: 'v1.0.0' })
await client.push('master')

// Conventional git client, which extends basic git client
const conventionalClient = new ConventionalGitClient(process.cwd())

console.log(await conventionalClient.getVersionFromTags()) // v1.0.0

API

new GitClient(cwd: string)

Create a wrapper around git CLI instance.

getRawCommits(params?: GitLogParams, restRawArgs?: string[]): AsyncIterable<string>

Get raw commits stream.

getTags(restRawArgs?: string[]): AsyncIterable<string>

Get tags stream.

checkIgnore(file: string, restRawArgs?: string[]): Promise<boolean>

Check file is ignored via .gitignore.

add(files: string | string[], restRawArgs?: string[]): Promise<void>

Add files to git index.

commit(params: GitCommitParams, restRawArgs?: string[]): Promise<void>

Commit changes.

tag(params: GitTagParams, restRawArgs?: string[]): Promise<void>

Create a tag for the current commit.

getCurrentBranch(restRawArgs?: string[]): Promise<string>

Get current branch name.

push(branch: string, restRawArgs?: string[]): Promise<void>

Push changes to remote.

new ConventionalGitClient(cwd: string)

Wrapper around Git CLI with conventional commits support.

getCommits(params?: ConventionalGitLogParams, parserOptions?: ParserStreamOptions, restRawArgs?: string[]): AsyncIterable<Commit>

Get parsed commits stream.

getSemverTags(params?: GitTagsLogParams, restRawArgs?: string[]): AsyncIterable<string>

Get semver tags stream.

getVersionFromTags(prefix?: string, restRawArgs?: string[]): Promise<string | null>

Get current sematic version from git tags.

License

MIT © Dan Onoshko

Keywords

FAQs

Last updated on 06 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc